﻿#include "module_interface.h"
#include "plc_library_export.h"
#include "plc_module.h"

extern "C" {

// 导出函数：创建PLC模块
PLC_LIBRARY_API IModule* createModule(QWidget* ui, ModbusManager* modbusManager, QObject* parent)
{
    return new PlcModule(ui, modbusManager, parent);
}

// 导出函数：获取模块名称
PLC_LIBRARY_API const char* getModuleName()
{
    return "PLC";
}

// 导出函数：创建工厂
PLC_LIBRARY_API IModuleFactory* createFactory()
{
    class PlcModuleFactory : public IModuleFactory
    {
    public:
        IModule* createModule(QWidget* ui, ModbusManager* modbusManager, QObject* parent = nullptr) override
        {
            return new PlcModule(ui, modbusManager, parent);
        }
        
        QString getModuleName() const override
        {
            return QString(u8"PLC");
        }
    };
    
    return new PlcModuleFactory();
}

}
